package com.insta.adapterList;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.insta.playdroid.R;
import com.insta.playdroid.metier.domain.Artist;

public class ArtistAdapter extends BaseAdapter {


	private List<Artist> artists = new ArrayList<Artist>();
	private LayoutInflater layoutInflater;
	
	
	
	public ArtistAdapter(Context context, List<Artist> all) {

		layoutInflater = LayoutInflater.from(context);
		this.artists = all;
	}
	
	private class ViewHolder {

		TextView artistName;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;

		if (convertView == null) {

			holder = new ViewHolder();

			convertView = layoutInflater.inflate(R.layout.songitem, null);

			holder.artistName = (TextView) convertView.findViewById(R.id.itemsong);

			convertView.setTag(holder);

		} else {

			holder = (ViewHolder) convertView.getTag();

		}

		holder.artistName.setText(artists.get(position).getName());

		return convertView;
	}

	@Override
	public int getCount() {
		return artists.size();
	}

	@Override
	public Object getItem(int pos) {
		return artists.get(pos);
	}

	@Override
	public long getItemId(int pos) {
		return pos;
	}
	
	public List<Artist> getArtists() {
		return artists;
	}

	public void setArtists(List<Artist> artists) {
		this.artists = artists;
	}

	public LayoutInflater getLayoutInflater() {
		return layoutInflater;
	}

	public void setLayoutInflater(LayoutInflater layoutInflater) {
		this.layoutInflater = layoutInflater;
	}

}
